package cn.wsalix.biz.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.SimpleEntity;
import cn.wsalix.admin.entity.SysUser;
import cn.wsalix.type.ParticipateEnum;

/**
 * @author jskyme 活动参与表
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "PARTICIPATE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(callSuper = false, exclude = { "participator" })
@ToString(exclude = "participator")
public class Participate extends SimpleEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6773976074323652415L;
	private ParticipateEnum partType;
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_PART_USER"), name = "USER_ID")
	private SysUser participator;
	
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_PART_MEETING"), name = "MEETING_ID")
	private Meeting meeting;
	
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_PART_ACTIVITY"), name = "ACTIVITY_ID")
	private Activity activity;
	private String username;
	private String phone;
	private String email;
	private String address;
}
